package com.chujian.framework.util.mybatis.wrapper;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.chujian.framework.core.tsdata.TsDataConst;

import java.util.Set;

/**
 * 需要忽略的列构建起
 */
public class FieldIgnoreWrapperBuilder implements IFieldWrapperBuilder {

    // 构造 QueryWrapper 时，忽略的字段
    public static final Set<String> ignoreConditionFields = CollUtil.newHashSet(
            "serialVersionUID",
            TsDataConst.COMMON_QUERY_FIELD
    );

    @Override
    public boolean build(WrapperUnit unit) {
        return null == unit.value // 值为空
                || ignoreConditionFields.contains(unit.fieldName) // 忽略的field
                || StrUtil.isEmpty(unit.col) // 非表列
                ;
    }
}
